package com.iot.blackip.mapper;

import com.iot.blackip.dto.Dc3BlackIpDto;
import com.iot.blackip.pojo.Dc3BlackIp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;

/**
 * @Author 咕唧
 * @Date 2022/7/20 19:23
 * @Version 1.0
 */
public interface Dc3BlackIpMapper {
    @SelectKey(statement = "select replace(UUID(),'-','')", keyProperty = "id", before = true, resultType = String.class)
    @Insert("insert into dc3_black_ip(id,ip,description) values(#{id},#{ip},#{description})")
    void addBlackIp(Dc3BlackIp dc3BlackIp);

    @Select("select ip,description from dc3_black_ip where enable = 1")
    List<Dc3BlackIpDto> findAllIp2Dto();

    @Delete("update dc3_black_ip set enable = 0,deleted = 1 where id = #{id}" )
    Long deleteBlackIp(String id);
}
